package register

import (
	"context"

	"server-go/api/reward/internal/svc"
	"server-go/api/reward/internal/types"
	"server-go/rpc/reward/types/reward"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetCaptchaLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetCaptchaLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCaptchaLogic {
	return &GetCaptchaLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetCaptchaLogic) GetCaptcha(req *types.GetCaptchaInput) (resp *types.GetCaptchaOutput, err error) {
	resp = new(types.GetCaptchaOutput)
	res, err := l.svcCtx.RewardRpc.GetCaptcha(l.ctx, &reward.GetCaptchaInput{Email: req.Email})
	if err != nil {
		return resp, err
	}
	resp.Status = res.Status
	resp.Data = res.Data
	return resp, nil
}
